from urllib import parse,request
import json
import zlib
textmod={'citykey':'101010100'}
textmod = parse.urlencode(textmod)
print(textmod)
#输出内容:user=admin&password=admin
header_dict = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko','Accept':'application/json, text/javascript, */*; q=0.01','Accept-Language':'zh-CN,zh;q=0.9'}
url='http://wthrcdn.etouch.cn/weather_mini'
req = request.Request(url='%s%s%s' % (url,'?',textmod),headers=header_dict)
res = request.urlopen(req)
res = res.read()
decompressed_data = zlib.decompress(res ,zlib.MAX_WBITS|32)  
#输出内容(python3默认获取到的是16进制'bytes'类型数据 Unicode编码，如果如需可读输出则需decode解码成对应编码):b'\xe7\x99\xbb\xe5\xbd\x95\xe6\x88\x90\xe5\x8a\x9f'
#print(str(res, encoding = "utf-8")  )
#print(res);
print(repr(decompressed_data))
#print(decompressed_data.decode(encoding='utf-8'))	
print(json.dumps(json.loads(decompressed_data.decode(encoding='utf-8'))))

print(repr(decompressed_data.decode(encoding='utf-8')))
#print(decompressed_data.decode(encoding='utf-8'))	